<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>选择服务站点</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-tab-content">
                    <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                        <div class="layui-form-item">

                            <div class="layui-inline">
                                <label class="layui-form-label">站点名称</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input class="layui-input" name="name" placeholder="请输入站点名称" autocomplete="off">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-search">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"> 搜索</i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <table class="layui-hide" id="test-table-reload" lay-filter="test-table-reload"></table>

                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="stationId" value="">
<input type="hidden" id="stationName" value="">
<input type="hidden" id="isIframe" value="${isIframe}">
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','utils', 'form'], function(){
        var $ = layui.$,
                table = layui.table,
                form = layui.form,
                admin = layui.admin;

        //监听搜索
        form.on("submit(LAY-search)", function (data) {
            var field = data.field;

            //执行重载
            table.reload('test-table-reload', {
                where: field
            });
        });

        //方法级渲染
        table.render({
            elem: '#test-table-reload'
            ,url: "/station/getStationList?isIframe=" + $("#isIframe").val()
            ,toolbar: '#test-table-reload-toolbar'
            ,defaultToolbar:['filter']
            ,cellMinWidth: 80
            ,cols: [[
                {type: 'checkbox'}
                , {field:'id', title: '站点ID', width: 100}
                , {field:'name', title: '站点名称', width: 200}
                , {field:'price', title: '服务金额'}
                , {field:'openStatusName', title: '营业状态'}
                , {field:'openTimeDesc', title: '营业时间'}
                , {field:'address', title: '营业地址', width: 240}
            ]]
            ,page: true
            ,height: 520
        });

        /**
         * 站点列表
         * iframe子页面向向父页面传值
         */
        table.on('checkbox(test-table-reload)', function () {
            var checkStatus = table.checkStatus('test-table-reload');
            var data = checkStatus.data; //得到checkbox选中的数据

            var stationId = [];
            var stationName = [];
            for (var i = 0; i < data.length; i++) {
                stationId.push(data[i].id);
                stationName.push(data[i].name);
            }
            $('#stationId').val(stationId);
            $('#stationName').val(stationName);
        });

    });
</script>
</body>
</html>